package com.itheima.File文件.file练习;

import java.io.File;
import java.util.HashMap;

public class 版本2统计文件个数 {
    static  HashMap<String, Integer> map = new HashMap<String, Integer>();

    public static void main(String[] args) {
        countFile(new File("day10可变参数和Stream流"));
        System.out.println(map);
    }

    private static void countFile(File file) {
        File[] files=file.listFiles();
        for (File file1 : files) {
            if(file1.isFile()){
                countCeil(file1);
            }else{
                countFile(file1);
            }
        }


    }

    private static void countCeil(File file1) {
        String name = file1.getName();
        String[] ss = name.split("\\.");
        if (ss.length == 2) {
            String firstname = ss[1];
            if (map.containsKey(firstname)) {
                int count = map.get(firstname);
                count++;
                map.put(firstname, count);
            } else {
                map.put(firstname, 1);
            }
        }
    }


}
